package com.alliky.home.ui.adapter;

import androidx.databinding.DataBindingUtil;

import com.alliky.core.entity.vo.CategoryVO;
import com.alliky.core.util.ImageLoader;
import com.alliky.home.R;
import com.alliky.home.databinding.ItemHomeCategoryLayoutBinding;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * @Author: wxianing
 * @CreateDate: 2022/7/31 16:20
 * @Description: java类作用描述
 */
public class CategoryAdapter extends BaseQuickAdapter<CategoryVO, BaseViewHolder> {

    public CategoryAdapter(@Nullable List<CategoryVO> data) {
        super(R.layout.item_home_category_layout, data);
    }

    @Override
    protected void onItemViewHolderCreated(@NotNull BaseViewHolder viewHolder, int viewType) {
        DataBindingUtil.bind(viewHolder.itemView);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, CategoryVO categoryVO) {
        ItemHomeCategoryLayoutBinding binding = holder.getBinding();
        ImageLoader.loadImage(getContext(), categoryVO.getThumb2(), binding.ivThumb);
        binding.tvName.setText(categoryVO.getCate_name());
    }
}
